<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>文章列表--layui后台管理模板 2.0</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="format-detection" content="telephone=no">
		<link rel="stylesheet" href="../../layui/css/layui.css" media="all" />
		<link rel="stylesheet" href="../../css/public.css" media="all" />
	</head>

	<body class="childrenBody">
		<div class="layui-form-item layui-row layui-col-xs12">
			<label class="layui-form-label">商品链接</label>
			<div class="layui-input-inline">
				<input type="text" name="renwu_good_url" class="layui-input renwu_good_url" lay-verify="required" placeholder="请输入链接后点击获取信息">
			</div>
			<div class="layui-form-mid layui-word-aux">
				<button id="get_goodmsg" class="layui-btn layui-btn-sm" lay-filter="get_goodmsg">获取信息</button>
			</div>
		</div>
		<form class="layui-form">
			<div class="layui-form-item layui-row layui-col-xs12">
				<label class="layui-form-label">店铺类型</label>
				<div class="layui-input-block renwu_shop_type">
					<input type="radio" name="renwu_shop_type" value="淘宝" title="淘宝" checked>
					<input type="radio" name="renwu_shop_type" value="京东" title="京东">
					<input type="radio" name="renwu_shop_type" value="拼多多" title="拼多多">
					<input type="radio" name="renwu_shop_type" value="阿里巴巴" title="阿里巴巴">
				</div>
			</div>
			<div class="layui-form-item layui-row layui-col-xs12">
				<label class="layui-form-label">下单方式</label>
				<div class="layui-input-block renwu_xiadan">
					<input type="radio" name="renwu_xiadan" value="无要求" title="无要求" checked>
					<input type="radio" name="renwu_xiadan" value="手机" title="手机">
					<input type="radio" name="renwu_xiadan" value="电脑" title="电脑">
				</div>
			</div>
			<div class="layui-form-item layui-row layui-col-xs12">
				<label class="layui-form-label">所属店铺</label>
				<div class="layui-input-block">
					<select name="renwu_good_shop" class="renwu_good_shop" id="renwu_good_shop" lay-filter="renwu_good_shop" lay-verify="required">
				        <option value=""></option>
				    </select>
				</div>
			</div>
			<div class="layui-form-item layui-row layui-col-xs12">
				<label class="layui-form-label">商品标题</label>
				<div class="layui-input-block">
					<input id="manager" type="hidden" name="manager" />
					<input id="user_name" type="hidden" name="user_name" />
					<input type="hidden" name="renwu_url" class="layui-input renwu_url" lay-verify="required" placeholder="请输入链接后点击获取信息">
					<input type="text" name="renwu_good_titles" class="layui-input renwu_good_titles" readonly lay-verify="required" placeholder="请输入商品链接获取商品标题">
				</div>
			</div>
			<div class="layui-form-item layui-row layui-col-xs12">
				<label class="layui-form-label">商品主图</label>
				<div class="layui-input-block">
					<input type="hidden" name="renwu_img_url" class="layui-input renwu_img_url" lay-verify="required" placeholder="请输入链接后点击获取信息">
					<img src="../../images/wk-tu_1.jpg" alt="商品主图" width="30%" id="renwu_good_img" class="renwu_good_img" />
				</div>
			</div>
			<div class="layui-form-item layui-row layui-col-xs12">
				<label class="layui-form-label">商品价格</label>
				<div class="layui-input-block">
					<input type="text" name="renwu_good_price" class="layui-input renwu_good_price" readonly lay-verify="required" placeholder="请输入商品链接获取商品价格">
				</div>
			</div>
			<div class="layui-form-item layui-row layui-col-xs12">
				<label class="layui-form-label">需付价格</label>
				<div class="layui-input-block">
					<input type="number" name="renwu_good_payPrice" class="layui-input renwu_good_payPrice" lay-verify="required" placeholder="请输入用户需要支付的总金额">
				</div>
			</div>
			<div class="layui-form-item layui-row layui-col-xs12">
				<label class="layui-form-label">搜索词</label>
				<div class="layui-input-block">
					<input type="text" name="renwu_good_searchWord" class="layui-input renwu_good_searchWord" lay-verify="required" placeholder="请输入搜索关键词">
				</div>
			</div>
			<div class="layui-form-item layui-row layui-col-xs12">
				<label class="layui-form-label">佣金</label>
				<div class="layui-input-block">
					<input type="number" name="renwu_good_money" class="layui-input renwu_good_money" lay-verify="required" placeholder="请输入本单任务佣金">
				</div>
			</div>
			<div class="layui-form-item layui-row layui-col-xs12">
				<label class="layui-form-label">其他要求</label>
				<div class="layui-input-block">
					<textarea class="layui-textarea renwu_yaoqiu" name="renwu_yaoqiu" id="renwu_yaoqiu" ></textarea>
				</div>
			</div>
			<div class="layui-form-item layui-row layui-col-xs12">
				<hr class="layui-bg-green" />
				<label style="color: red;">
					*注意：请注意核对填写信息，若因为信息填写错误导致任务失败，平台概不负责！！！
				</label>
			</div>
			<div class="layui-form-item layui-row layui-col-xs12">
				<div class="layui-input-block">
					<button id="addrenwu" class="layui-btn layui-btn-sm" lay-submit="" lay-filter="addrenwu">立即添加</button>
					<button type="reset" class="layui-btn layui-btn-sm layui-btn-primary">取消</button>
				</div>
			</div>
		</form>
		<script type="text/javascript" src="../../layui/layui.js"></script>
		<script src="../../js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="renwuAdd1.js"></script>
		<script type="text/javascript">
			layui.use(['form', 'layer', 'laydate', 'table', 'laytpl'], function() {
				var form = layui.form,
					layer = parent.layer === undefined ? layui.layer : top.layer,
					$ = layui.jquery,
					laydate = layui.laydate,
					laytpl = layui.laytpl,
					table = layui.table,
					laypage = layui.laypage;
					//$("#shili").show();
					$("#user_name").val(localStorage.login_name);
				console.log("1");
				var selectwangwang 	= "";
				var good_wangwang	= "";
				
				//获取下拉框的值
				$.ajax({
					type:"get",
					url:"http://127.0.0.1:88/index.php/renwu/renwu/select",
					data:"user="+localStorage.login_name,
					success:function(res){
						//console.log(res.data);
						//$(".renwu_wangwang").empty();
						var optionString="";
						$.each(res.data,function(key,value){
							$("#renwu_good_shop").append(new Option(value,value));
							optionString += '<option value="'+value+'">'+value+'</option>';
						});
						//console.log(optionString);
						layui.form.render('select');
						//$("#renwu_wangwang").html(optionString);
					}
				});
				form.on("submit(addrenwu)",function(data){
					//弹出loading
					//alert($("#file").val());
					var index = top.layer.msg('数据提交中，请稍候',{icon: 16,time:false,shade:0.8});
					var action 	= data.form.action;//表单提交URL地址
					$.post("http://127.0.0.1:88/index.php/renwu/renwu/addRenwu",data.field,function(obj){
						if (obj.code==200) {
							setTimeout(function(){
								top.layer.close(index);
								top.layer.msg(obj.msg);
								layer.closeAll("iframe");
								//刷新父页面
								parent.location.reload();
							},2000); 
						} else{
							setTimeout(function(){
							top.layer.msg(obj.msg);
							//刷新父页面
						},2000); 
						}
					});
					
					return false;
			    })
				
				$("#get_goodmsg").click(function(){
					if($(".renwu_good_url").val()==""){
						layer.msg("请输入商品链接！");
					}else{
						$.ajax({
							type:"post",
							url:"http://127.0.0.1:88/index.php/general/taobao/clicb",
							data:"url="+encodeURIComponent($(".renwu_good_url").val()),
							dataType: "JSON",
							success:function(res){
								
								//console.log(wangwang);
								layer.msg("数据获取结束");
								/*var a = res.manager;
								good_wangwang = a.substr(3);
								if(wangwang!=good_wangwang){
									layer.msg("当前店铺联系方式与商品不一致，请重新选择");
								}*/
								setTimeout(function(){
									$(".renwu_good_titles").val(res.titles);
									$(".user_name").val(res.titles);
									$(".renwu_good_price").val(res.price);
									$("#manager").val(res.manager);
									$(".renwu_url").val($(".renwu_good_url").val());
									$(".renwu_img_url").val(res.images);
									$(".renwu_good_img").attr("src",res.images);
								},100);
								//return false;
								
								
							}
						});
					}
				})
				/*$("#renwu_wangwang").change(function(){
					/*var value	= $("#renwu_wangwang option:selected").val();
					console.log(value);
					if(value!=good_wangwang){
						layer.msg(good_wangwang);
					}*/
				/*	alert("1");
				});*/
				if ($(".renwu_wangwang").attr("checked")==true) {
					console.log($(".renwu_wangwang option:selected").text());
				}
				
			})
			
		</script>
	</body>

</html>